<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="custom" tagdir="/WEB-INF/tags" %>
<html>
<body>
<form:form commandName="formDto" id="form">
    <form:hidden path="caseUuid"/>
    <div class="modal-header">
        <button type="button" class="close"
                data-dismiss="modal" aria-hidden="true">
            &times;
        </button>
        <h4 class="modal-title" id="myModalLabel">
            案件上报
        </h4>
    </div>
    <div class="modal-body">
        <div class="form-group">
            <div class="col-sm-12"><h4 class="panel-title">常用回复</h4></div>
        </div>
        <div class="form-group">
            <div class="col-sm-12">
                <select class="form-control" id="replySet">
                    <option value="">请选择常用回复</option>
                    <c:forEach items="${formDto.replySetList}" var="item">
                        <option value="${item.content}">${item.name}</option>
                    </c:forEach>
                </select>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-12">
                <textarea name="content" id="content" class="form-control" rows="5" placeholder="上报原因"
                          required="required"></textarea><br/>
                <span class="error text-danger ErrorText"></span>
            </div>
        </div>
        <c:if test="${sessionScope.employee.inspector}">
            <div class="form-group">
                <label class="col-sm-2 control-label">
                    上报至平台
                    &nbsp;&nbsp;&nbsp;
                    <form:checkbox path="reportPlatform"/>
                </label>
                <span class="fa fa-info-circle" data-container="body" data-toggle="popover"
                      data-placement="right" data-content="如勾选则上报到平台中进行处置" data-original-title=""
                      title=""></span>
                <script type="text/javascript">
                    $('[data-toggle="popover"]').popover({html: true});
                </script>
            </div>
        </c:if>
    </div>
    <div class="modal-footer">
        <button type="button" class="btn btn-primary" id="SubmitBtn">
            确定
        </button>
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭
        </button>
    </div>
</form:form>
<script type="text/javascript">
    $("#replySet").change(function () {
        var val = $(this).children('option:selected').val();
        $("#content").val(val);
    });

    $("#SubmitBtn").click(function () {
        var serialize = $("#form").serialize();
        $.ajax({
            url: 'report',
            data: serialize,
            type: 'post',
            cache: false,
            success: function (data) {
                if (data.state) {
                    window.location.reload();
                } else {
                    $(".ErrorText").html(data.msg);
                }
            },
            error: function () {
                alert("失败");
            }
        });
    });
</script>
</body>
</html>
